package de.tum.in.eist.poll.client;


import java.util.Date;

import junit.framework.TestCase;

import org.junit.Test;
import com.google.gwt.junit.client.*;
import com.google.gwt.user.client.rpc.AsyncCallback;

import de.tum.in.eist.poll.server.PollDataControl;
import de.tum.in.eist.poll.server.UserManagement;
import de.tum.in.eist.poll.shared.Feedback;
import de.tum.in.eist.poll.shared.Lecture;
import de.tum.in.eist.poll.shared.Lecturer;
import de.tum.in.eist.poll.shared.Student;
import de.tum.in.eist.poll.shared.User;

public class EIST_POLLTest extends  TestCase{

	@Test
	public final void testLogin(){
		UserManagement managment = new UserManagement();
		Student[] students = new Student[25];
		for(int i = 0; i < 25; i++){
			students[i] = new Student("student"+i,"pass"+i);
			managment.registerUser(students[i]);
		}
		for(int i = 0; i < 25; i++){
			assertEquals(students[i], managment.login(students[i].getName(), students[i].getPassword()));
		}
	}
	
	@Test
	public final void testPollDataControll(){
		PollDataControl control = new PollDataControl();
		Lecture[] lectures = new Lecture[25];
		for(int i = 0; i < 25; i++){
			lectures[i] = new Lecture(""+i, "eist"+i, new Date(i), new Lecturer("lecturer", "eist"));
		}
		Student[] students = new Student[25];
		for(int i = 0; i < 25; i++){
			for(int j = 0; j < 25; j++){
				students[i] = new Student("student"+i,"pass"+i);
				control.saveFeedback(new Feedback(lectures[j]), students[i]);
			}
		}
		for(int i = 0; i < 25; i++){
			assertEquals(25, control.getFeedback(lectures[i].getLectureID(), lectures[i].getCurrentLectureDate()).size());
		}
	}
	
}

				
